package gui;

import gui.display.Display;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import utils.ServerConnection;

/**
 *
 */
public class ChatsPanel extends JPanel
{
    private final ServersPanel servers_ = new ServersPanel( this );
    private Display currentDisplay_;

    /**
     *
     */
    public ChatsPanel()
    {
        super( new BorderLayout() );

        setSize( 300, 100 );
        add( servers_, BorderLayout.WEST );
    }

    /**
     *
     * @param server
     */
    public final void add( ServerConnection server )
    {
        servers_.add( server );
        setCurrentDisplay(server.getDisplay());
        validate();
    }

    /**
     *
     * @param display
     */
    public final void setCurrentDisplay( Display display )
    {
        if( currentDisplay_ != null )
            remove( currentDisplay_ );
        currentDisplay_ = display;
        add( currentDisplay_, BorderLayout.CENTER );
        validate();
        repaint();
    }
}
